// https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/

public int RemoveDuplicates(int[] nums)
{
    if (nums.Length == 0)
        return 0;
    int count = 0;
    for (int i = 1; i <= nums.Length - 1; i++)
    {
        if (nums[i] != nums[count])
        {
            count++;
            nums[count] = nums[i];
        }
    }
    return ++count;
}